<?php

namespace Modules\Shop\Entities;

use App\Models\ModuleModel;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
 * 评论
 * @package Modules\Shop\Entities
 */
class Comment extends ModuleModel
{
    use HasFactory;

    protected $table = 'shop_comment';

    protected $fillable = ['site_id', 'user_id', 'goods_id', 'comment_id', 'images', 'content'];

    protected $casts = ['images' => 'array', 'comment_id' => 'integer'];

    protected static function newFactory()
    {
        return \Modules\Shop\Database\factories\CommentFactory::new();
    }

    /**
     * 回复
     * @return HasMany
     */
    public function replys()
    {
        return $this->hasMany(Comment::class, 'comment_id');
    }
}
